namespace IAM.Interface.Model
{
    using IAM.Interface.Model.Interface;
    using System;
    using System.Collections;
    using System.Reflection;
    using System.Text;
    using System.Xml;

    public class ACISession : AbstractConvertObject, IConvertXml
    {
        private ArrayList _acisession = null;

        public ACISession()
        {
            this._acisession = new ArrayList();
        }

        public override object ConvertToObject()
        {
            foreach (XmlNode xn in this.CurrentXmlNode.ChildNodes)
            {
                CheckedItem checkeditem = new CheckedItem();
                checkeditem.CurrentXmlNode = xn;
                checkeditem = (CheckedItem) checkeditem.ConvertToObject();
                this.Items.Add(checkeditem);
            }
            return this;
        }

        public override bool Equals(object obj)
        {
            ACISession acisession = null;
            try
            {
                acisession = (ACISession) obj;
            }
            catch
            {
                return false;
            }
            if (this.Items.Count != acisession.Items.Count)
            {
                return false;
            }
            bool boolforeach = true;
            foreach (object rudeobj in this.Items)
            {
                boolforeach = false;
                foreach (object aimobj in acisession.Items)
                {
                    if (((CheckedItem) rudeobj).Equals(aimobj))
                    {
                        boolforeach = true;
                        break;
                    }
                }
                if (!boolforeach)
                {
                    return boolforeach;
                }
            }
            return boolforeach;
        }

        public override int GetHashCode()
        {
            int result = 1;
            PropertyInfo[] pi = base.GetType().GetProperties();
            foreach (PropertyInfo onofpi in pi)
            {
                result += onofpi.GetHashCode();
            }
            return result;
        }

        public ArrayList Items
        {
            get
            {
                return this._acisession;
            }
            set
            {
                this._acisession = value;
            }
        }

        public string XML
        {
            get
            {
                return (this.XMLBoday + this.XMLFinis);
            }
        }

        public string XMLBoday
        {
            get
            {
                StringBuilder _xml = new StringBuilder();
                _xml.Append("<ACISession>");
                foreach (object checkeditem in this.Items)
                {
                    _xml.Append(((CheckedItem) checkeditem).XML);
                }
                return _xml.ToString();
            }
        }

        public string XMLFinis
        {
            get
            {
                return "</ACISession>";
            }
        }
    }
}
